
** OPEN STATA 14 ***


use "POLITICAL EMANCIPATION -- POLAND DATA SET.dta", clear

global covariates "jewishpop"

* FIGURE 6 including CONFIDENCE INTERVALS -- polynomial of 1
 
* Generate vars, then use them
 
rdplot capzionschoolsno_any distance if type=="ville", nbins(30 30) binselect(qs) p(1) graph_options(graphregion(color(white)) xtitle(Distance to Russian Pale Border in Meters, size(small) margin(medsmall)) ytitle(Zionist Schools per 1000 Jews - Pinkas, size(small) margin(medsmall)) ylabel(0(.2)1) xlabel(,labsize(small) format(%9.0gc)) title(Figure 6. Zionist Schools in Towns, size(medlarge) margin(medsmall))) genvars

*generate variable to use 1 observation per bin in the scatter plot
 
sort rdplot_id id
 
gen lagrdplot_id=rdplot_id[_n-1]

gen bin_for_plot=1 if rdplot_id!=lagrdplot_id & rdplot_id!=.

twoway (lfitci rdplot_mean_y distance if distance<0, clcolor(black) ciplot(rline) blcolor(black) blpattern(dash)) (lfitci rdplot_mean_y distance if distance>0, clcolor(black) ciplot(rline) blcolor(black) blpattern(dash)) (scatter rdplot_mean_y distance if bin_for_plot==1, mcolor(black) msize(small) msymbol(circle_hollow)), ytitle(Zionist Schools per 1000 Jews - Pinkas) ytitle(, margin(medsmall)) yscale(range(0(.2)1.2)) ylabel(0(.2)1.2) yline(0 (.2) 1.2, lwidth(thin) lpattern(dot) lcolor(gray)) xtitle(Distance (West to East) to Russian Pale Boundary in Meters, size(medsmall) margin(medsmall)) xline(0, lwidth(medium) lcolor(black)) title(Figure 6. Zionist Schools in Towns, size(medlarge) margin(medsmall)) legend(off) scheme(s1mono)

graph save "FINAL EMPIRICS\empirics - rdd\figures 6 and 7\figure6-p1.gph", replace

* FOR APSR, without TITLE

twoway (lfitci rdplot_mean_y distance if distance<0, clcolor(black) ciplot(rline) blcolor(black) blpattern(dash)) (lfitci rdplot_mean_y distance if distance>0, clcolor(black) ciplot(rline) blcolor(black) blpattern(dash)) (scatter rdplot_mean_y distance if bin_for_plot==1, mcolor(black) msize(small) msymbol(circle_hollow)), ytitle(Zionist Schools per 1000 Jews - Pinkas) ytitle(, margin(medsmall)) yscale(range(0(.2)1.2)) ylabel(0(.2)1.2) yline(0 (.2) 1.2, lwidth(thin) lpattern(dot) lcolor(gray)) xtitle(Distance (West to East) to Russian Pale Boundary in Meters, size(medsmall) margin(medsmall)) xline(0, lwidth(medium) lcolor(black)) legend(off) scheme(s1mono)

graph save "FINAL EMPIRICS\empirics - rdd\figures 6 and 7\figure6-APSR.gph", replace


drop rdplot_id rdplot_N rdplot_min_bin rdplot_max_bin rdplot_mean_bin rdplot_mean_x rdplot_mean_y rdplot_se_y rdplot_ci_l rdplot_ci_r rdplot_hat_y lagrdplot_id bin_for_plot


* FIGURE 7 including CONFIDENCE INTERVALS -- POLYNOMIAL OF 1

* clean slate if I just created Fig 6 with conf intervals

*drop rdplot_id rdplot_N rdplot_min_bin rdplot_max_bin rdplot_mean_bin rdplot_mean_x rdplot_mean_y rdplot_se_y rdplot_ci_l rdplot_ci_r rdplot_hat_y lagrdplot_id bin_for_plot

* rdplot with genvars:

rdplot capmax_zschools_census distance if type=="ville",  nbins(30 30) binselect(qs) p(1) graph_options(graphregion(color(white)) xtitle(Distance to border between Congress and Russian Pale, size(small) margin(medsmall)) ytitle(Tarbut and Yavne Schools per 1000 J -- Census, size(small) margin(medsmall)) ylabel(0(.2)1) xlabel(,labsize(small) format(%9.0gc)) legend(size(small))  title(Figure 7. Tarbut and Yavne Schools. All Towns, size(medium) margin(medsmall))) genvars

* generate variable to use 1 observation per bin in the scatter plot

sort rdplot_id id
gen lagrdplot_id=rdplot_id[_n-1]
gen bin_for_plot=1 if rdplot_id!=lagrdplot_id & rdplot_id!=.

* then generate graph

twoway (lfitci rdplot_mean_y distance if distance<0, clcolor(black) ciplot(rline) blcolor(black) blpattern(dash)) (lfitci rdplot_mean_y distance if distance>0, clcolor(black) ciplot(rline) blcolor(black) blpattern(dash)) (scatter rdplot_mean_y distance if bin_for_plot==1, mcolor(black) msize(small) msymbol(circle_hollow)), ytitle(Tarbut and Yavne Schools per 1000 Jews -- Census, size(medsmall) margin(medsmall)) ytitle(, margin(medsmall)) yscale(range(0 .8)) ylabel(0(.2).8) yline(0 (.2) .8, lwidth(thin) lpattern(dot) lcolor(gray)) xtitle(Distance (West to East) to Russian Pale Boundary in Meters, size(medsmall) margin(medsmall)) xline(0, lwidth(medium) lcolor(black)) title(Figure 7. Tarbut and Yavne Schools. Towns, size(medium) margin(medsmall)) legend(off) scheme(s1mono)

graph save "FINAL EMPIRICS\empirics - rdd\figures 6 and 7\figure7-p1.gph", replace

* FOR APSR, without TITLE

twoway (lfitci rdplot_mean_y distance if distance<0, clcolor(black) ciplot(rline) blcolor(black) blpattern(dash)) (lfitci rdplot_mean_y distance if distance>0, clcolor(black) ciplot(rline) blcolor(black) blpattern(dash)) (scatter rdplot_mean_y distance if bin_for_plot==1, mcolor(black) msize(small) msymbol(circle_hollow)), ytitle(Tarbut and Yavne Schools per 1000 Jews -- Census, size(medsmall) margin(medsmall)) ytitle(, margin(medsmall)) yscale(range(0 .8)) ylabel(0(.2).8) yline(0 (.2) .8, lwidth(thin) lpattern(dot) lcolor(gray)) xtitle(Distance (West to East) to Russian Pale Boundary in Meters, size(medsmall) margin(medsmall)) xline(0, lwidth(medium) lcolor(black))  legend(off) scheme(s1mono)


graph save "FINAL EMPIRICS\empirics - rdd\figures 6 and 7\figure7-APSR.gph", replace


* then drop generate variables before saving file:

drop rdplot_id rdplot_N rdplot_min_bin rdplot_max_bin rdplot_mean_bin rdplot_mean_x rdplot_mean_y rdplot_se_y rdplot_ci_l rdplot_ci_r rdplot_hat_y lagrdplot_id bin_for_plot

